package vsy.buzzwordbingo.sort;

import vsy.buzzwordbingo.model.Game;

public class GameOwnerComparator extends OrderedComparator<Game> {
	public GameOwnerComparator(Order order) {
		super(order);
	}

	@Override
	public int orderedCompare(Game g1, Game g2) {
		if (g1.getOwner() == null || g2.getOwner() == null)
			return nullCompare(g1.getTitle(), g2.getTitle());
		
		if (g1.getOwner().getName() == null || g2.getOwner().getName() == null)
			return nullCompare(g1.getTitle(), g2.getTitle());
		
		return g1.getOwner().getName().compareTo(g2.getOwner().getName());
	}
}
